package ai.people.platform.archives.service.impl;

import ai.people.netmon.framework.domain.archives.entity.ArchivesUserAssociation;
import ai.people.platform.archives.mapper.ArchivesUserAssociationMapper;
import ai.people.platform.archives.service.ArchivesUserAssociationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhenglin
 * @since 2022-03-30
 */
@Service
@RequiredArgsConstructor
public class ArchivesUserAssociationServiceImpl extends ServiceImpl<ArchivesUserAssociationMapper, ArchivesUserAssociation> implements ArchivesUserAssociationService {

    /**
     * 档案用户关系映射器
     */
    private final ArchivesUserAssociationMapper archivesUserAssociationMapper;


    /**
     * 通过用户id查询列表
     *
     * @param archiveId 档案id
     * @return {@link List}<{@link ArchivesUserAssociation}>
     */
    @Override
    public List<ArchivesUserAssociation> listAllByUserIds(Long archiveId) {
        LambdaQueryWrapper<ArchivesUserAssociation> lambdaQuery = Wrappers.lambdaQuery(ArchivesUserAssociation.class);
        lambdaQuery.eq(ArchivesUserAssociation::getArchivesId, archiveId);
        return archivesUserAssociationMapper.selectList(lambdaQuery);
    }
}
